/**
 * 扩展数组函数，是否包含指定元素
 * @param {Object} obj
 */
Array.prototype.contains = function (obj) {
    var i = this.length;
    while (i--) {
        if (this[i] === obj) {
            return true;
        }
    }
    return false;
}

export function isDef(v) {
    return v !== undefined && v !== null
}

/**
 * Remove an item from an array.
 */
export function remove(arr, item) {
    if (arr.length) {
        const index = arr.indexOf(item)
        if (index > -1) {
            return arr.splice(index, 1)
        }
    }
}

export function isRegExp(v) {
    return _toString.call(v) === '[object RegExp]'
}

const _toString = Object.prototype.toString

/**
 * 根据起止年份，获取年份列表
 * @param {Object} startYear
 * @param {Object} endYear
 */
export function getYears(startYear, endYear) {
    let years = []
    for (let i = startYear; i <= endYear; i++) {
        years.push(i)
    }
    return years
}